-
Notifications
You must be signed in to change notification settings - Fork 997
Implemented methods login() and findByEmail() #1266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
sarakhmen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's improve your solution :)
| */ | ||
| public boolean login(String email, String password) { | ||
| return false; | ||
| UserService userService = new UserService(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initialize this service in class fields
| if (newUser != null) { | ||
| return newUser.getPassword().equals(password); | ||
| } else { | ||
| return false; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use ternary operator here
| public boolean login(String email, String password) { | ||
| return false; | ||
| UserService userService = new UserService(); | ||
| User newUser = userService.findByEmail(email); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename this variable to be clear and correct in terms of the context
src/main/java/mate/academy/Main.java
Outdated
| private static String str = new String("hello".toCharArray()); | ||
|
|
||
| public static void main(String[] args) { | ||
| test("[email protected]", "1234", true); | ||
| test("[email protected]", "1234", true); | ||
| test("[email protected]", "1234", false); | ||
| test("[email protected]", "qwerty", false); | ||
| } | ||
|
|
||
| private static void test(String email, String password, boolean expected) { | ||
| boolean actual = authenticationService.login(email, password); | ||
| if (expected == actual) { | ||
| System.out.println("Test passed for email: " + email + " and password " + password); | ||
| } else { | ||
| System.out.print("Expected to receive " + expected + ", but was " + actual + ". "); | ||
| System.out.println("Email: " + email + ", password " + password); | ||
| } | ||
| } | ||
|
|
||
| public static void smth(String s) { | ||
| String s21 = str.intern(); | ||
| System.out.println(); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert these changes
Elena-Bruyako
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one comment
src/main/java/mate/academy/Main.java
Outdated
| private static String str = new String("hello".toCharArray()); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
| private static String str = new String("hello".toCharArray()); |
No description provided.